#include <DApplication>
#include <QDate>
#include <QDir>
#include <QDebug>
#include "MainWindow.h"
#include "DataCenter.h"

DWIDGET_USE_NAMESPACE

int main(int argc, char *argv[])
{
    // TODO 在 taskList中增加底线，表示任务全部列举完成.
    DApplication::setQuitOnLastWindowClosed(false); // 关闭窗口时，程序不退出
    DApplication a(argc, argv);
    a.setAttribute(Qt::AA_UseHighDpiPixmaps);
    a.setApplicationName("calendar-desktop-widget");
    a.setApplicationVersion("v0.0.1");
    a.loadTranslator();

    if (a.setSingleInstance(a.applicationName()))
    {
        notifyUser(QObject::tr("show on the desktop"));
    }
    else
    {
        notifyUser(QObject::tr("already shown on the desktop"));
        return 1;
    }

    QDir::home().mkpath("./.local/share/calendar-desktop-widget");
    DataCenter::instance().loadData(QDir::homePath() + "/.local/share/calendar-desktop-widget/data");


    MainWindow w;
    w.show();
    w.lower();

    int rc = a.exec();
    DataCenter::instance().mainWindowPos = w.pos();
    DataCenter::instance().saveData();
    return rc;
}
